package com.wkn.wknAdmin.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;


/**
 * @Title:
 * @Description:
 * @Author: WKN
 * CreateDate: 2022/8/12 14:57
 */
@Configuration
@EnableOpenApi
public class SwaggerConfig {


    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2) //每个docket都可以分一个组
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.wkn.wknAdmin.controller")) //扫描指定的包
                .paths(PathSelectors.any())//扫描全部
                .build()
                .groupName("wkn");
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("项目接口文档html")
                .version("1.0")
                .build();
    }
}
